package com.hitqz.robot.driver.zmq.protocol.handler;

import com.example.tutorial.AddressBookProtos;
import com.hitqz.robot.driver.util.WheelCacheUtil;
import com.hitqz.robot.driver.util.WheelToolkit;
import lombok.extern.slf4j.Slf4j;
import navconnector.ChassisXc;
import navconnector.ChassisYichun;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;

@Slf4j
@Component
public class ChassisXCInt32Handler implements HandlerZMQService {

    @Override
    public void handlerMsg(String robotSn, byte[] data) throws Exception {
        ChassisXc.ChassisXCInt32 chassisXCInt32 = ChassisXc.ChassisXCInt32.parseFrom(data);
        String type = chassisXCInt32.getDescriptorForType().getName();
        int ackId = chassisXCInt32.getHeader().getAck();
        int objId = chassisXCInt32.getHeader().getObj();

        if (objId == ChassisXc.ChassisXCInt32.OBJ_ID.GET_LOCALIZATION_LIGHT_REP_VALUE) {
            int status = chassisXCInt32.getData();
            WheelCacheUtil.put(WheelCacheUtil.KEY_LIGHT_STATUS,status);
        }
        //释放锁
        WheelToolkit.release(ackId,type,objId,true);

    }


}
